package org.hhchat.leetcode.tree;

import org.hhchat.leetcode.dataStruct.TreeNode;


/**
 * dfs
 * https://leetcode.com/problems/path-sum/description/
 */
public class code112_easy {
    class Solution {
        int sum=0;
        public boolean hasPathSum(TreeNode root, int sum) {
            if(root==null){
                return false;
            }
            if(root.left==null&&root.right==null){
                return root.val==sum;
            }
            return hasPathSum(root.left,sum-root.val)||hasPathSum(root.right,sum-root.val);
        }
    }

    public static void main(String[] args){

    }

}
